/******************************************************************************
 * SAGE - Scalable Adaptive Graphics Environment
 *
 * Module: sageVirtualDesktop.h
 * Author : Byungil Jeong
 *
 * Copyright (C) 2004 Electronic Visualization Laboratory,
 * University of Illinois at Chicago
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either Version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser Public License along
 * with this library; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * Direct questions, comments etc about SAGE to bijeong@evl.uic.edu or 
 * http://www.evl.uic.edu/cavern/forum/
 *
 *****************************************************************************/

#ifndef _SAGE_VIRTUAL_DESKTOP_H
#define _SAGE_VIRTUAL_DESKTOP_H

#include "sage.h"
#include "tileConfig.h"

class streamInfo;
class streamGroup;
class fsManager;

class sageVirtualDesktop : public virtualDesktop {
public:	
	std::vector<int> tileNodeList;	// nodeIDs of display nodes
	std::vector<int> clientList;		// clientIDs of display nodes

#ifdef SAGE_AUDIO
        std::vector<int> audioNodeList;         // nodeIDs of audio nodes
        std::vector<int> audioClientList;       // clientIDs of audio nodes
#endif

	fsManager *fsm;

	sageVirtualDesktop();
	~sageVirtualDesktop();
	int init(fsManager *f) { fsm = f; }		
	int generateStreamInfo(streamGroup &sGrp, std::vector<int> &rcvList);
	int launchReceivers(char *fsIP, int port);
        int launchAudioReceivers(char *fsIP, int port);
	
	int getRcvId(int nodeId);
	int getNodeNum() { return displayCluster.size(); }
	int getTileNum() { return tileList.size(); }
	int getNodeId(int tileId) { return tileList[tileId]->nodeID; }
	int getNodeIPs(int nodeId, char *ipStr);
	
	int getRcvInfo(int nodeId, char *info);
	int regRcv(int cId, int nodeId);

#ifdef SAGE_AUDIO
        int getAudioRcvId(int nodeId);
        int getAudioRcvInfo(int nodeId, char *info);
        int regAudioRcv(int cId, int nodeId);
        int getAudioNodeIPs(int nodeId, char *ipStr);
        int generateAudioStreamInfo(streamGroup &sGrp, std::vector<int> &rcvList);
        int generateAudioRcvInfo(int port, char* msgStr);
        int generateAudioRcvInfo(char* ip, int port, char* msgStr);
	std::vector<int> getAudioRcvClientList() { return audioClientList; }
#endif

	std::vector<int> getRcvClientList() { return clientList; }

	int changeBGColor(int red, int green, int blue);
	int takeSnapshot();
	int sendToAll(int code, char *data);
	int convertYaxis(int y) { return height - y; }	
};	

#endif

